import 'package:flutter/cupertino.dart';
import 'package:jetour_line/utils/extension_int.dart';

class SliverListWidget {
  static SliverList getSliverList(int itemCount, IndexedWidgetBuilder builder) {
    return SliverList(delegate: SliverChildBuilderDelegate(builder, childCount: itemCount));
  }

  static getSliverContainer(double? height, Widget widget, {bool? pinned}) {
    return SliverPersistentHeader(
        pinned: pinned ?? false,
        delegate: StickyTabBarDelegate(
          height: height ?? 100.px,
          child: widget,
        ));
  }
}

class StickyTabBarDelegate extends SliverPersistentHeaderDelegate {
  final Widget child;
  final double height;
  StickyTabBarDelegate({required this.child, this.height = 50});
  @override


  Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
    return child;

  }

  @override
  double get maxExtent => height;
  @override
  double get minExtent => height;
  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate oldDelegate) {
    return true;
  }
}
